import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'; // Nodejs内置的路径管理插件

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      // __dirname是Nodejs内置全局对象，用来获取当前文件所在目录的绝对路径
      "@": path.resolve(__dirname, 'src')
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://nocat.life:3013',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  }
})
